package com.baidu.baidumap;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.baidu.mapapi.SDKInitializer;

public class MainActivity extends AppCompatActivity {
    private static String[] objects = new String[] { "hello world", "图层", "圆形覆盖物",
             "展示文字", "marker覆盖物", "矩形范围内搜索", "圆形区域", "全城搜索", "驾车路线",
            "步行路线", "公交换乘", "我的位置" };
    private static Class[] clazzs = new Class[] { HelloActivity.class,
            LayerDemo.class
           , CircleOptionsDemo.class,  TextOptionsDemo.class,
            MarkerOptionsDemo.class, PoiSearchInBoundsDemo.class,
             PoiSearchNearByDemo.class,  PoiSearchInCityDemo.class,
            DrivingRouteOverlayDemo.class, WalkingRouteOverlayDemo.class,
            TransitRouteOverlayDemo.class ,LocationDemo.class};
    private ListView list;
    private ArrayAdapter<String> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        list = (ListView) findViewById(R.id.lv_listview);
        adapter = new ArrayAdapter<String>(getApplicationContext(),R.layout.item,objects);
        list.setAdapter(adapter);
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(getApplicationContext(),clazzs[position]);
                startActivity(intent);
            }

        });
        SDKInitializer.initialize(getApplicationContext());
    }
}
